package com.kancy.streamplus.config;

import com.kancy.streamplus.channel.AutoSubscribeChannelPostProcessor;
import com.kancy.streamplus.channel.DynamicChannelResolver;
import com.kancy.streamplus.channel.PollingChannel;
import com.kancy.streamplus.properties.StreamPlusProperties;
import com.kancy.streamplus.service.PollingMessageService;
import com.kancy.streamplus.service.impl.PollingMessageServiceImpl;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
 * StreamPlusAutoConfiguration
 *
 * @author kancy
 * @date 2020/3/22 15:41
 */
@EnableConfigurationProperties({StreamPlusProperties.class})
@Import({PollingMessageDispatcherAutoConfiguration.class, AutoSubscribeChannelPostProcessor.class})
public class StreamPlusAutoConfiguration {

    @Bean
    public DynamicInterfaceBeanResolver dynamicInterfaceBeanResolver(){
        return new DynamicInterfaceBeanResolver();
    }

    @Bean
    public DynamicChannelResolver dynamicChannelResolver(){
        return new DynamicChannelResolver();
    }

    @Bean
    public PollingMessageService pollingMessageService(StreamPlusProperties streamPlusProperties,
                                                       DynamicChannelResolver dynamicChannelResolver,
                                                       PollingChannel pollingChannel){
        return new PollingMessageServiceImpl(streamPlusProperties, dynamicChannelResolver, pollingChannel);
    }
}
